package com.sdhs.paas.sdk.core.web;

import java.util.List;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Configuration;
import org.springframework.http.HttpStatus;

/**
 * http协议配置
 *
 * @author wjj
 *
 */
@Configuration
@ConfigurationProperties(prefix = "shtelpaas.http")
public class PaasHttpProperties {

	private String reqVerNo = "1.0"; // 请求协议版本号
	private String reqTestFlag = "0"; // 0-正常 1-测试
	private String reqType = "0"; // 0-正常 1-测试

	private String repVerNo = "1.0"; // 响应协议版本号

	@Value("${spring.application.name}")
	private String RepServUnitName;
//	@Value("${spring.cloud.config.profile}")
	private String RepServUnitVersion;
	// private String RepTimestamp; //这个值有问题，每个请求会有n个这种数据，不应该输出在状态位
	@Value("${spring.cloud.client.hostname}")
	private String siHostname;
//	@Value("${spring.cloud.client.ipAddress}")
	private String siIP;
	@Value("${server.port}")
	private String siPort;
	@Value("${spring.application.name}")
	private String siName;
	@Value("${spring.cloud.client.hostname}:${spring.application.name}:${server.port}")
	private String siDesc;

	// 异常处理模式，为了兼容之前异常在每个服务都被处理成200，所以设置一个标志位，默认还是处理成200，如果配置了mode为500，那么处理成抛出异常
	private int exceptionMode = HttpStatus.OK.value();

	private boolean enableIdempotence;
	private String idempotenceCheckUrl = "http://shtelPaasCache/checkIdempotence/{1}";
	private String idempotenceCommitUrl = "http://shtelPaasCache/commitIdempotence/{1}/{2}/{3}"; // 幂等性校验服务地址
	private List<String> excludeIdempotence;

	public String getReqVerNo() {
		return reqVerNo;
	}

	public void setReqVerNo(String reqVerNo) {
		this.reqVerNo = reqVerNo;
	}

	public String getReqTestFlag() {
		return reqTestFlag;
	}

	public void setReqTestFlag(String reqTestFlag) {
		this.reqTestFlag = reqTestFlag;
	}

	public String getRepVerNo() {
		return repVerNo;
	}

	public void setRepVerNo(String repVerNo) {
		this.repVerNo = repVerNo;
	}

	public String getRepServUnitName() {
		return RepServUnitName;
	}

	public void setRepServUnitName(String repServUnitName) {
		RepServUnitName = repServUnitName;
	}

	public String getRepServUnitVersion() {
		return RepServUnitVersion;
	}

	public void setRepServUnitVersion(String repServUnitVersion) {
		RepServUnitVersion = repServUnitVersion;
	}

	public String getSiHostname() {
		return siHostname;
	}

	public void setSiHostname(String siHostname) {
		this.siHostname = siHostname;
	}

	public String getSiIP() {
		return siIP;
	}

	public void setSiIP(String siIP) {
		this.siIP = siIP;
	}

	public String getSiPort() {
		return siPort;
	}

	public void setSiPort(String siPort) {
		this.siPort = siPort;
	}

	public String getReqType() {
		return reqType;
	}

	public void setReqType(String reqType) {
		this.reqType = reqType;
	}

	public String getSiName() {
		return siName;
	}

	public void setSiName(String siName) {
		this.siName = siName;
	}

	public String getSiDesc() {
		return siDesc;
	}

	public void setSiDesc(String siDesc) {
		this.siDesc = siDesc;
	}

	public List<String> getExcludeIdempotence() {
		return excludeIdempotence;
	}

	public void setExcludeIdempotence(List<String> excludeIdempotence) {
		this.excludeIdempotence = excludeIdempotence;
	}

	public boolean isEnableIdempotence() {
		return enableIdempotence;
	}

	public void setEnableIdempotence(boolean enableIdempotence) {
		this.enableIdempotence = enableIdempotence;
	}

	public String getIdempotenceCheckUrl() {
		return idempotenceCheckUrl;
	}

	public void setIdempotenceCheckUrl(String idempotenceCheckUrl) {
		this.idempotenceCheckUrl = idempotenceCheckUrl;
	}

	public String getIdempotenceCommitUrl() {
		return idempotenceCommitUrl;
	}

	public void setIdempotenceCommitUrl(String idempotenceCommitUrl) {
		this.idempotenceCommitUrl = idempotenceCommitUrl;
	}

	public int getExceptionMode() {
		return exceptionMode;
	}

	public void setExceptionMode(int exceptionMode) {
		this.exceptionMode = exceptionMode;
	}

}
